<template>
  <page-header-wrapper>
    <!-- <global-search ref="globalSearch" :list="searchList" @search="handleSearch" @reset="handleReset"> </global-search> -->
    <a-card :bordered="false" class="search-card m-b-20">
      <div class="table-page-search-wrapper">
        <a-form layout="inline">
          <a-row :gutter="48">
            <a-col :md="14" :lg="12" :xl="8" :sm="24">
              <a-form-item label="项目名称">
                <a-input
                  v-model="queryParam.strContent.FW_XMMC"
                  placeholder="请输入项目名称"
                  @pressEnter="$refs.table.refresh(true)"
                />
              </a-form-item>
            </a-col>
            <a-col :md="14" :lg="12" :xl="8" :sm="24">
              <a-form-item label="房源代码">
                <a-input
                  v-model="queryParam.strContent.FW_FYDM"
                  placeholder="请输入房源代码"
                  @pressEnter="$refs.table.refresh(true)"
                />
              </a-form-item>
            </a-col>
            <a-col :md="10" :lg="8" :xl="8" :sm="24">
              <span class="table-page-search-submitButtons">
                <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
                <a-button style="margin-left: 8px" @click="handleReset">重置</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </a-card>
    <a-card :bordered="false">
      <s-table
        ref="table"
        size="default"
        :rowKey="(record, index) => index"
        :columns="columns"
        :data="loadData"
        :scroll="{ x: true }"
        :pagination="{ showTotal: (total) => `共 ${total} 条` }"
      >
        <span slot="index" slot-scope="text, record, index">{{ index + 1 }} </span>
      </s-table>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import { STable, Ellipsis } from '@/components'
import { getStatementList } from '@/api/statementAndStatistics'
export default {
  components: {
    STable,
    Ellipsis,
  },
  data() {
    return {
      searchList: [
        {
          label: '年度',
          fields: 'Years',
          type: 'year',
          props: {
            placeholder: '请选择年度',
          },
        },
        {
          label: '季度',
          fields: 'Quarter',
          type: 'select',
          props: {
            placeholder: '请选择季度',
            options: [
              {
                label: '第一季度',
                value: 1,
              },
              {
                label: '第二季度',
                value: 2,
              },
              {
                label: '第三季度',
                value: 3,
              },
              {
                label: '第四季度',
                value: 4,
              },
            ],
          },
        },
      ],
      queryParam: {
        Mode: 'QRKZFYZKZ',
        UserID: this.$store.getters.userid,
        strContent: {},
      },
      columns: [
        {
          title: '序号',
          width: 80,
          align: 'center',
          scopedSlots: { customRender: 'index' },
        },
        {
          title: '项目名称',
          align: 'center',
          dataIndex: 'FW_XMMC',
        },
        {
          title: '栋',
          align: 'center',
          dataIndex: 'FW_D',
        },
        {
          title: '单元',
          align: 'center',
          dataIndex: 'FW_DY',
        },
        {
          title: '楼层',
          align: 'center',
          dataIndex: 'FW_LC',
        },
        {
          title: '附号',
          align: 'center',
          dataIndex: 'FW_FH',
        },
        {
          title: '面积',
          align: 'center',
          dataIndex: 'FW_MJ',
        },
        {
          title: '当前状态',
          align: 'center',
          dataIndex: 'FW_DQZT',
        },
        {
          title: '房源代码',
          align: 'center',
          dataIndex: 'FW_FYDM',
        },
        {
          title: '申请编号',
          align: 'center',
          dataIndex: 'DQRZ_SQBH',
        },
        {
          title: '申请人',
          align: 'center',
          dataIndex: 'DQRZ_SQR',
        },
        {
          title: '身份证号',
          align: 'center',
          dataIndex: 'DQRZ_SFZH',
        },
        {
          title: '保障方式',
          align: 'center',
          dataIndex: 'DQRZ_BZFS',
        },
        {
          title: '分配时间',
          align: 'center',
          dataIndex: 'DQRZ_FPSJ',
        },
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: (parameter) => {
        const requestParameters = Object.assign({}, parameter, this.queryParam)
        return getStatementList(requestParameters).then((res) => res)
      },
    }
  },
  methods: {
    handleSearch(values) {
      this.queryParam.strContent = values
      this.tableRefresh(true)
    },
    handleReset() {
      this.queryParam.strContent = {}
      this.tableRefresh(true)
    },
    tableRefresh(refresh = false) {
      this.$refs.table.refresh(refresh)
    },
  },
}
</script>
<style lang="less" scoped>
/deep/ .ant-table td {
  white-space: nowrap;
}
</style>
